home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Re: Embedding Binary Data File in .EXE
- Date: 27 Feb 1996 08:38:49 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4gvc2pINNdf7@anvil.ugrad.cs.ubc.ca>
- References: <312b88d2.13833883@news.uwaterloo.ca>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <312b88d2.13833883@news.uwaterloo.ca>,
- Mark Nebelung <mrnebelu@undergrad.math.uwaterloo.ca> wrote:
- >Hi there,
- >
- >I was just wondering on the best way to embed a binary file in an
- >executible.
- >
- >I have an FLI file that I would like to make self-executible. I have
- >all the display routines, but now I just want to know how I can tag on
- >the FLI file to my display executible.
- >
- >I using Borland C++, and the code is to run under DOS.
-
- One obvious way is to declare a big array of type char, and store the FLI in
- there. A simple utility program can be written that will turn binary files
- into C array declarations.
-
- You then compile and link the result. The intermediate C code for the
- declaration will likely be somewhat of a bloat, of course, on the order of at
- least 5x bigger than the original datafile.
-
- Have your program spit out something like:
-
- char data[] = {
- 0xff,0x39,0x55,0xeD,...
- };
-
- The sizeof(data) will give you the number of bytes in the array.
-
- Of course, the platform you are working on probably won't let you have arrays
- bigger than 64K unless you mess with some weird memory model business.
-
- Ad-hoc techniques like appending data to executable files not something I'd
- recommend, though.
-
- This is the closest thing to a C answer that I can come up with.
-
- --
-
-